package com.mall.dubbo.api;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mall.dubbo.mapper.UmsRoleResourceRelationMapper;
import com.mall.model.domain.UmsRoleResourceRelation;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @author xyiaao
 * @description 针对表【ums_role_resource_relation(后台角色资源关系表)】的数据库操作Api实现
 * @createDate 2022-03-29 19:46:09
 */
@DubboService
public class UmsRoleResourceRelationApiImpl extends ServiceImpl<UmsRoleResourceRelationMapper, UmsRoleResourceRelation>
        implements UmsRoleResourceRelationApi {

    @Autowired
    private UmsRoleResourceRelationMapper umsRoleResourceRelationMapper;

    @Override
    public List<UmsRoleResourceRelation> findByIds(List<Long> ids) {

        LambdaQueryWrapper<UmsRoleResourceRelation> lqw = new LambdaQueryWrapper<>();
        lqw.in(CollUtil.isNotEmpty(ids), UmsRoleResourceRelation::getRoleId, ids);

        return umsRoleResourceRelationMapper.selectList(lqw);
    }

    @Override
    public void delete(List<Long> ids) {

        LambdaQueryWrapper<UmsRoleResourceRelation> lqw = new LambdaQueryWrapper<>();
        lqw.in(CollUtil.isNotEmpty(ids), UmsRoleResourceRelation::getRoleId, ids);

        umsRoleResourceRelationMapper.delete(lqw);
    }

    @Override
    public List<UmsRoleResourceRelation> findByRoleId(Integer roleId) {

        LambdaQueryWrapper<UmsRoleResourceRelation> lqw = new LambdaQueryWrapper<>();
        lqw.eq(roleId != null, UmsRoleResourceRelation::getRoleId, roleId);

        return umsRoleResourceRelationMapper.selectList(lqw);
    }

}




